﻿using B.S.DataBase.Domain;
using B.S.DataBase.ErrorCode;
using B.S.DataBase.Read.API.Application.Commands.GetProduct;
using B.S.DataBase.Read.API.Application.Commands.GetSelectProduct;
using B.S.DataBase.Read.API.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.DataBase.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        private readonly IMediator mediator;

        public ManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 查询商品信息(下拉框)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<ProductType>>> GetProductType([FromQuery] GetSelectProductType request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 商品信息显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<ProductDto>> GetProduct([FromQuery] GetProductCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
